﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace PMQLNhaHang.Utils
{
    public class XmlHelper
    {
        public static XmlHelper _xmlhelper;
        private string tenNhaHang;
        private string sdt;
        private string diaDiem;
        private XmlElement root;
        protected XmlHelper()
        {
            root = LoadXML("CauHinh.xml");
            if(root!=null)
            {
                tenNhaHang = root.GetElementsByTagName("TenNhaHang").Item(0).InnerText;
                sdt = root.GetElementsByTagName("SDT").Item(0).InnerText;
                diaDiem = root.GetElementsByTagName("DiaDiem").Item(0).InnerText;
            }
        }

        public string TenNhaHang
        {
            get { return tenNhaHang; }
            set { tenNhaHang = value; }
        }
        public string Sdt
        {
            get { return sdt; }
            set { sdt = value; }
        }
        public string DiaDiem
        {
            get { return diaDiem; }
            set { diaDiem = value; }
        }

        public static XmlHelper Instances()
        {
            if(_xmlhelper==null)
            {
                _xmlhelper = new XmlHelper();
            }
            return _xmlhelper;
        }
        public static XmlElement LoadXML(string path)
        {
            XmlElement root;
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            root = doc.DocumentElement;
            if (root != null)
                return root;
            return null;
        }

    }
}
